﻿Public Class frmOtroCargos
    Dim cargo As New clsOtrosCargos
    Dim Bitacora As New clsActividad
    Private Sub frmOtroCargos_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ToolStrip2.Cursor = Cursors.Hand
        ToolStrip2.RenderMode = System.Windows.Forms.ToolStripRenderMode.System
        ToolStrip2.Stretch = True

        txtID.Text = EmpleadoID
        txtNomEmp.Text = frmModuloEmpleadosDetalle.txtPaterno.Text.Trim & " " & frmModuloEmpleadosDetalle.txtMaterno.Text.Trim & " " & frmModuloEmpleadosDetalle.txtNombre.Text.Trim
        txtDescuento.Text = 0
        txtMonto.Text = 0
        txtMotivo.Text = ""
        txtTiempo.Text = 0
        datFecha.Value = Now()
    End Sub

    Private Sub txtTiempo_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtTiempo.TextChanged
        If Me.txtTiempo.Text = "" Then
            Exit Sub

        End If
        If Me.txtTiempo.Text = 0 Then
            Exit Sub

        End If

        Me.txtDescuento.Text = CDbl(Me.txtMonto.Text) / CInt(Me.txtTiempo.Text)
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)



    End Sub

    Private Sub txtMonto_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtMonto.TextChanged
        If Me.txtMonto.Text = "" Then
            txtMonto.Text = 0

        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


    End Sub

    Private Sub toolGuardar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub toolSalir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.Close()
    End Sub

    Private Sub ToolStripButton5_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripButton5.Click

        If Me.txtMotivo.Text = "" Then
            MsgBox("Debes indicar el motivo", MsgBoxStyle.Exclamation, "Aviso")
            Exit Sub
        End If
        If Me.txtMonto.Text = 0 Then
            MsgBox("Debes indicar el monto", MsgBoxStyle.Exclamation, "Aviso")
            Exit Sub
        End If
        If Me.txtDescuento.Text = "" Then
            MsgBox("Debes indicar el descuento por nomina", MsgBoxStyle.Exclamation, "Aviso")
            Exit Sub
        End If
        If Me.lstTipo.Text = "" Then
            MsgBox("Debes indicar el tipo de descuento", MsgBoxStyle.Exclamation, "Aviso")
            Exit Sub
        End If


        cargo.idCargo = (BuscarIntDatoCitra("SELECT max(IDCargo) as Id FROM OtrosCargos")) + 1
        cargo.idempleado = Me.txtID.Text
        cargo.Motivo = Me.txtMotivo.Text
        cargo.Monto = Me.txtMonto.Text
        cargo.Tiempo = Me.txtTiempo.Text
        cargo.Tipo = Me.lstTipo.Text
        cargo.Descuento = Me.txtDescuento.Text
        cargo.Capturo = UsuarioActivo
        cargo.Reportado = "No"
        cargo.fecha = Me.datFecha.Value
        cargo.FechaRegistro = datRegistro.Value
        cargo.Insertar()

        Bitacora.RegistraActividad("Registro cargos varios a " & txtNomEmp.Text.Trim)


        frmModuloEmpleadosDetalle.cargaOtros()
        Me.Close()
    End Sub

    Private Sub ToolStripButton1_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripButton1.Click
        Close()

    End Sub
End Class